package com.xal.controller;

import com.xal.pojo.Student;
import com.xal.service.StudentService;
import com.xal.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: MybatisSpriingBoot
 * @author: 邢奥林
 * @create: 2023-04-10 19:41
 **/
@RestController
public class StudentController {

    @Autowired
    private StudentService studentService;

    //查
    @GetMapping("/findById/{sid}")
    public Result findById(@PathVariable Integer sid){
        Result byId = studentService.findById(sid);
        return byId;
    }
    @GetMapping("/findAll")
    public Result findAll(){
        Result all = studentService.findAll();
        return all;

    }
    //增
    @PostMapping("insert")
    public  Result insert(@RequestBody Student student){
        Result insert = studentService.insert(student);
        return insert;
    }
    //改
    @PutMapping("/update")
    public  Result result(@RequestBody Student student){
        Result update = studentService.update(student);
        return update;
    }
    @DeleteMapping("delete/{sid}")
    public Result delete(@PathVariable Integer sid){
        Result delete = studentService.delete(sid);
        return delete;
    }


}
